-- card: 16849 from stack: in.5 -- bmap block id: 18713 -- flags: 0000 -- background id: 3858 -- name: LocalVolumeList ----- HyperTalk script ----- on CloseCard put empty into cd fld "volumes" set the scroll of cd fld "volumes" to 0 pass CloseCard end CloseCard on HideObjects hide cd fld "volumes" hide cd btn "All Volumes" hide cd btn "Local Volumes" end HideObjects on ShowObjects show cd fld "volumes" show cd btn "All Volumes" show cd btn "Local Volumes" end ShowObjects -- part 1 (button) -- low flags: 00 -- high flags: A002 -- rect: left=128 top=298 right=326 bottom=236 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 8192 -- line height: 16 -- part name: Local Volumes ----- HyperTalk script ----- on mouseUp global errGlobal set cursor to watch put LocalVolumeList("noDialog:errGlobal") into volInfo if errGlobal ≠ empty then answer "Error: “" & errGlobal & "”" put empty into errGlobal else put volInfo into cd fld "volumes" end if end mouseUp -- part 2 (button) -- low flags: 00 -- high flags: A002 -- rect: left=18 top=298 right=326 bottom=126 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 1 -- font id: 0 -- text size: 12 -- style flags: 0 -- line height: 16 -- part name: All Volumes ----- HyperTalk script ----- on mouseUp global errGlobal set cursor to watch put VolumeList("", "noDialog:errGlobal") into volInfo if errGlobal ≠ empty then answer "Error: “" & errGlobal & "”" put empty into errGlobal else put volInfo into cd fld "volumes" end if end mouseUp -- part 3 (field) -- low flags: 00 -- high flags: 0007 -- rect: left=19 top=117 right=288 bottom=236 -- title width / last selected line: 0 -- icon id / first selected line: 0 / 0 -- text alignment: 0 -- font id: 4 -- text size: 9 -- style flags: 0 -- line height: 12 -- part name: Volumes -- part contents for background part 38 ----- text ----- 27/50 -- part contents for background part 20 ----- text ----- An XFCN which returns a carraige return delimited list of all locally mounted volumes - in other words non server volumes. LocalVolumeList(["noDialog:"errorGlobal]) It correctly reports floppy drives and SCSI drives (traditional Hard drives, SyQuest drives, and CD-ROM drives) as local volumes. I have written it so that it should correctly report a Mac XL internal HD or HD20 as a local volume, but I haven't been able to test it. -- part contents for background part 42 ----- text ----- unit LocalVolumeList; {} { brought to you by: Anup Murarka Eric Carlson } { ALINK: SKEPTIC ALINK: cyNic } { CIS: 76004,3356 } {} { We are part of the Support Tools Development Group, } { Apple Computer, Inc. } {} { please DO NOT contack Mac DTS for support of this code! } {} { please DO contact the authors for support of this code! } {} { Send comments, bug reports, requests to any of the above } { E-mail addresses or to:} {} { (one of us) } { Apple Computer, Inc. } { 900 E. Hamilton, Ave. } { Campbell, CA 95008 } { M/S 72-L } {} { Copyright: © 1989, 1990 by Apple Computer, Inc., all rights reserved. } {} { written by Eric Carlson } { AppleLink: cyNic } { modification history } { Date Initials Comments } { ---- ------ ------------------------------------------------------} { 5/3/90 ec first written } {} interface uses HyperXCmd; procedure MAIN (paramPtr: XCmdPtr); implementation type VCBPtr = ^VCB; procedure reportToUser (paramPtr: XCmdPtr; msgStr: str255); {} { report something back to the user. } { the last parameter (optional) to an external may contain } { "noDialog" or "noDialog:GlobalName". GlobalName is the name } { of a HyperTalk global variable into which error messages will be } { placed. we've decided to use this approach to avoid confusing } { an error message with a valid result being returned from an XFCN. } {} var tempStr: str255; begin {check the last param to see if the user requested that} { we suppress the error dialog } ZeroToPas(paramPtr, paramPtr^.params[paramPtr^.paramCount]^, tempStr); UprString(tempStr, true); if pos('NODIALOG', tempStr) = 0 then { no special error handling specified, throw up a dialog and return the error message } begin SendCardMessage(paramPtr, concat('answer "', msgStr, '"')); paramPtr^.returnValue := PasToZero(paramPtr, msgStr); end else if (pos(':', tempStr) > 0) then { requested global AND noDialog so we fill in the global and return empty } begin tempStr := copy(tempStr, pos(':', tempStr) + 1, length(tempStr)); { get the name of the HC global to fill } SetGlobal(paramPtr, tempStr, PasToZero(paramPtr, msgStr)); { and fill it } paramPtr^.returnValue := PasToZero(paramPtr, ''); { return empty } end else { requested noDialog only so we return the error condition as the result } paramPtr^.returnValue := PasToZero(paramPtr, msgStr); end; { procedure } function AskedForHelp (paramPtr: XCmdPtr; syntaxMsg: Str255; copyrightMsg: Str255): boolean; { check to see if the user sent a '?' or a '!' as } { the only parameter. if so we will respond with } { the calling syntax or the copyright/version info } { for this external } {} var firstStr: str255; begin askedForHelp := false; if paramPtr^.paramCount = 1 then begin ZeroToPas(paramPtr, paramPtr^.params[1]^, firstStr); { what is the first param? } if firstStr = '?' then begin reportToUser(paramPtr, syntaxMsg); askedForHelp := true end { asked for help } else if firstStr = '!' then begin reportToUser(paramPtr, copyRightMsg); askedForHelp := true end; { asked for copyright info } end; { one parameter passed } end; { function } function AppendString (hndl: Handle; newStr: Str255): OSErr; {} { stick the string onto the back of the handle } {} begin AppendString := PtrAndHand(Ptr(ORD4(@newStr) + 1), hndl, LENGTH(newStr)); end; procedure LocalVolumeList (paramPtr: XCmdPtr); var volList: handle; err: OSErr; aQueElement: VCBPtr; headPtr: QHdrPtr; unitTableSlot: integer; begin if askedForHelp(paramPtr, 'LocalVolumeList(<“noDialog:”errorGlobal>)', 'v1.0, ©1990 Apple Computer ,Inc, Eric Carlson . ') then exit(LocalVolumeList); volList := NewHandle(0); { use a handle for the list in case someone has more that 255 chars worth of drives } err := MemError; { handle allocated OK? } if err <> noErr then begin reportToUser(paramPtr, 'Out of memory.'); exit(LocalVolumeList); end; headPtr := GetVCBQHdr; { grab the vcb que header } if headPtr <> nil then begin aQueElement := VCBPtr(headPtr^.qHead); while aQueElement <> nil do { now step through all of the VCB entries } begin unitTableSlot := BITNOT(aQueElement^.vcbDRefNum); { the unit table entry number, IM IV-215 } if (unitTableSlot in [32..39]) or (unitTableSlot = 4) or (unitTableSlot = 1) then begin { entry numbers 32-39 are for SCSI drivers 0-7, entry number 4 is for Sony driver (floppy), } { entry number 1 is for a Mac XL internal or HD20 } err := AppendString(volList, concat(aQueElement^.vcbVN, chr(13))); { remember the volume name } if err <> noErr then begin reportToUser(paramPtr, 'Out of memory.'); if volList <> nil then DisposHandle(volList); exit(LocalVolumeList); end; end; aQueElement := VCBPtr(aQueElement^.qLink); end; end; { VCB ptr <> nil } if volList <> nil then begin SetHandleSize(volList, GetHandleSize(volList) - 1); { drop the trailing comma } err := AppendString(volList, chr(0)); { Terminate with 0 byte } if err <> noErr then reportToUser(paramPtr, 'Out of memory.'); end; paramPtr^.returnValue := volList; end; { procedure LocalDiskList} procedure MAIN (paramPtr: XCmdPtr); begin LocalVolumeList(paramPtr); end; end. { unit FileExists}